app.controller('homeController', function ($scope, $controller, homeService) {

    $controller("baseController", {$scope: $scope});
    $controller("indexController", {$scope: $scope});

    $scope.homeParam = {};

    //获取home页参数
    $scope.findHomeParam = function () {

        homeService.findHomeParam().success(function (response) {

            if (response.code == 200) {
                $scope.homeParam = response.data;
            }
        })

    };


    //获取江西服务费
    $scope.findJXServerFeeBalance = function () {

        homeService.findJXServerFeeBalance().success(function (response) {

            if (response.code == 200) {
                $scope.JXServerFee = response.data.subAccBalance;
                $scope.shadowSubAccountBalance = response.data.shadowSubAccountBalance;
            }
        })
    };

    //获取俊派服务费
    $scope.findJunPaiServerFeeBalance = function () {

        homeService.findJunPaiServerFeeBalance().success(function (response) {

            if (response.code == 200) {
                $scope.JPServerFee = response.msg;
            }
        })
    };

    //获取安徽俭派服务费
    $scope.findAnHuiJianPaiServerFeeBalance = function () {

        homeService.findAnHuiJianPaiServerFeeBalance().success(function (response) {

            if (response.code == 200) {
                $scope.AnHuiJianPaiServerFee = response.msg;
            }
        })
    };

    //获取河南穗优服务费
    $scope.findHeNanSuiYouServerFeeBalance = function () {

        homeService.findHeNanSuiYouServerFeeBalance().success(function (response) {

            if (response.code == 200) {
                $scope.HeNanSuiYouServerFee = response.msg;
            }
        })
    };

    $scope.findZheJiangXiangJianServerFeeBalance = function () {
        if ($scope.ZHEJIANGXIANGJIAN) {
            homeService.findZheJiangXiangJianServerFeeBalance().success(function (res) {
                if (res.code == 200) {
                    $scope.xiangjianServiceAccountBalance = res.data;
                }
            })
        }
    }

    $scope.initServiceFee =function() {
        if ($scope.matchValue) {
            $scope.findPingAnServiceFeeBalance()
            $scope.findZhiFuBaoServiceFeeBalance()
        }
    }

    $scope.matchValue = ''
    $scope.pingAnServiceFeeBalanceList = []
    $scope.zhiFuBaoServiceFeeBalanceList = []

    $scope.findPingAnServiceFeeBalance = function() {
        homeService.selectPinAnServiceFees({matchValue: $scope.matchValue}).success(function (res) {
            $scope.pingAnServiceFeeBalanceList = res.data
            console.log($scope.pingAnServiceFeeBalanceList)
        })
    }

    $scope.findZhiFuBaoServiceFeeBalance = function() {
        homeService.selectZhiFuBaoServiceFees({matchValue: $scope.matchValue}).success(function (res) {
            $scope.zhiFuBaoServiceFeeBalanceList = res.data
            console.log($scope.zhiFuBaoServiceFeeBalanceList)
        })
    }

    $scope.JiangXiSuiYou = false;
    $scope.JiangXiJunPai = false;
    $scope.AnHuiJianPai = false;
    $scope.HeNanSuiYou = false;
    $scope.ZHEJIANGXIANGJIAN = false;

    $scope.initModel = function () {

        var enCodeManagerStr = sessionStorage.getItem("MANAGER");

        //base64解码
        var managerStr = decodeURIComponent(window.atob(enCodeManagerStr));

        var manager = JSON.parse(managerStr);

        var matchValue = manager.matchValue;

        $scope.matchValue = matchValue

        console.log("matchValue-" + matchValue)

        switch (matchValue) {
            case '江西省穗优':
                $scope.JiangXiSuiYou = true;
                break;
            case '江西俊派':
                $scope.JiangXiJunPai = true;
                break;
            case '安徽俭派':
                $scope.AnHuiJianPai = true;
                break;
            case '河南穗优':
                $scope.HeNanSuiYou = true;
            case '浙江相间':
                $scope.ZHEJIANGXIANGJIAN = true;
        }

    };

    $scope.showMoneyInfo = false;
    $scope.clickSwitch = function () {
        console.log("执行。。")
        if ($scope.showMoneyInfo) {

            $scope.showMoneyInfo = false;
        } else {
            $scope.showMoneyInfo = true;

        }
    }

});